import type { VxeGridProps } from '@vben/plugins/vxe-table';

export const useFosoTable = (options: any) => {
  const { columns, data, requestApi } = options;
  const tableConfig = ref<VxeGridProps>({
    columns,
    size: 'medium',
    data,
    rowConfig: {
      isHover: true, // 开启悬浮行高亮
    },
    proxyConfig: {
      ajax: {
        query: async (page: any) => {
          const { currentPage, pageSize } = page.page;
          return await requestApi({ page: currentPage, pageSize });
        },
      },
    },
    autoResize: true, // 启用自动调整大小
    pagerConfig: {
      pageSize: 20, // 每页显示的行数
    },
    toolbarConfig: {
      custom: true,
      export: true,
      import: true,
      refresh: true,
      zoom: true,
    },

    border: true,
  });
  return {
    tableConfig,
    data,
    columns,
  };
};
